<!DOCTYPE html>
<html lang="ar">
<head>
    <title>قائمة الموردين</title>
	<?php
	 define('LAST_CAPITRE_ID',19);
	 define('LAST_ARTICLE_CODE',3);
	?>
	
	<?php $this->load->helper('url');?>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
	<meta charset="utf-8">
	 <!-- //////////////////////////// javascript for jstree ///////////////////// -->
	<script type="text/javascript" src="<?php echo base_url('assets/js/jstree/_lib/jquery.js');?>" ></script>
    <script type="text/javascript" src="<?php echo base_url('assets/js/jstree/_lib/jquery.cookie.js');?>" ></script>
	<script type="text/javascript" src="<?php echo base_url('assets/js/jstree/_lib/jquery.hotkeys.js');?>" ></script>
	<script type="text/javascript" src="<?php echo base_url('assets/js/jstree/jquery.jstree.js');?>" ></script>
	<script type="text/javascript" src="<?php echo base_url('assets/js/jstree/_docs/syntax/!script.js');?>" ></script>
	<!-- //////////////////////////// javascript for jstree ///////////////////// -->
	
	<!-- //////////////////////////// css for jstree ///////////////////// -->
	<link href="<?php echo base_url("assets/js/jstree/_docs/syntax/!style.css")?>" rel="stylesheet" type="text/css" />
	<link href="<?php echo base_url("assets/js/jstree/_docs/!style.css")?>" rel="stylesheet" type="text/css" />
	<!-- //////////////////////////// css for jstree ///////////////////// -->
	
	<!--amiri font  -->   
	<!--<link href='<?php echo base_url("assets/css/webfonts/amiri/amiri.css")?>"' rel="stylesheet" type="text/css" />-->
	
	<!-- cssfor buttons and list layout -->
	<!--<link href="<?php echo base_url("assets/css/main_menu_style.css")?>" rel="stylesheet" type="text/css" /> -->
	
	
</head>


<?php include_once('header.php');

		 $this->load->library('session');
        $num_ar=$this->session->userdata('data_charticle'); //access it
        $chcl=$num_ar['charticle'];
	  //  $chcl = $charticle['charticle'];  
	//	$frns=$fournisseur['fournisseur'];
 ?>


<div id="charticle_tree" class="demo" style="direction: rtl; float: right;">
<ul>
		<?php // get all the chapitres and article from the database and echo them in ul and li for  rendering with Jtree
		$mem =0;
	
		
		for($i = 0; $i < count($chcl); $i++)
		{
			
			if($mem <> $chcl[$i]->id_chapitre)
			{
			echo('	<li id=ch_'.$chcl[$i]->id_chapitre.'>
			<a href="#">'.$chcl[$i]->id_chapitre.' '.$chcl[$i]->nom_chap.'</a>
			<ul>
				<li id='.$chcl[$i]->id_article.'>
					<a href="#">'.$chcl[$i]->code.' '.$chcl[$i]->nom_art.'</a>
				</li>');
			}
			else
			{
				echo('<li id='.$chcl[$i]->id_article.'>
					<a href="#">'.$chcl[$i]->code.' '.$chcl[$i]->nom_art.'</a>
				</li>');
				
				
				if (isset($chcl[$i+1]->code))
					{ 
					if($chcl[$i]->code > $chcl[$i+1]->code )
					echo('</ul></li>');
					}
			}
		if(($chcl[$i]->code)== 1 && ($chcl[$i]->id_chapitre == 16)) echo('</ul></li>'); // patch to fix a unique leaf	
		if(($chcl[$i]->code)== LAST_ARTICLE_CODE && ($chcl[$i]->id_chapitre == LAST_CAPITRE_ID)) echo('</ul></li>');  //patch to fix the last leaf	
		
        $mem = $chcl[$i]->id_chapitre;

		}
		unset($mem);
		?>
</ul>
</div>
<div>
	
	
</div>
<div id="destination" >

<head>
<?php $this->load->helper('url');?>
	<meta http-equiv="content-type" content="text/html; charset=UTF-8"/>
<style>

.even
{
background-color:#fdddf4;	
}
.odd
{
background-color:#A7C942;
}
.t_header{
	background-color: #50af9e;
}

</style>

</head>
 <div id="container">
  <h1>الموردون</h1>
  <div id="body">
  
  ////
  <table style="width:300px ; border-bottom-style: solid; border-color: #ff0000;">
<tr>
  <th class="t_header">id</th>
  <th class="t_header">fournisseur</th>
  <th class="t_header">action</th>
</tr>

<?php
foreach($results as $data) 
{ $tstyle = "";
if($data->id_fournisseur %2 ==0 ) {	$tstyle = "even";} else {$tstyle = "odd";}

	
	echo '<tr class = '.$tstyle.'>
	      <td><a href="http://www.iqama3000.com/iqama_04_05_14/pagination_ctr">'.$data->id_fournisseur.'</a></td>
	      <td>'.$data->nom.'</td>
		  <td> <a href = "xxxxxx/chemin/facture_"'.$data->adresse.'</td>
		  </tr>'  ;
	
}
?>
</table>



<!--pagination here--> 
   <p><?php echo $links; ?></p>
  </div>
  <p class="footer">Page rendered in <strong>{elapsed_time}</strong> seconds</p>
 </div>
</body>

 
</div>


<script type="text/javascript" class="source below">
$('#loading').hide().ajaxStart( function() {$(this).show();}).ajaxStop ( function(){$(this).hide();}); // show loading div dduring ajax load


$(function () { 
	// TO CREATE AN INSTANCE
	// select the tree container using jQuery
	$("#charticle_tree")
		// call `.jstree` with the options object
		.jstree({"themes" : {
	            "theme" : "default-rtl",
	            "dots" : true,
	            "icons" : true
	        },
			"plugins" : ["themes","html_data","ui","crrm","hotkeys"],
			"core" : { "initially_open" : [ "ch_6" ] }
				})
		.bind("loaded.jstree", function (event, data) {})
		
		.bind("select_node.jstree", function (event, data) { 
		     var record_id = data.rslt.obj.attr("id"); // get the "id" of the selected item
		     var p = {};  //prepare an array to be sent to the controller as a $_POST array
		     p['record_id'] = record_id; 
		   //  $('#destination').load('fournisseur_ctr/get_fournisseurs_per_article2',p,function(str){  }); //load the controller output into the destination div
             //alert(record_id);
			  //location.href= " get_fournisseurs_per_article2/"+record_id;
			  
			//   window.location.href = "get_fournisseurs_per_article2/"+record_id;
			   window.location.href = "http://www.iqama3000.com/iqama_04_05_14/fournisseur_ctr/get_fournisseurs_per_article2/"+record_id;
		}).delegate("a", "click", function (event, data) { event.preventDefault(); });
	
	
		
	//setTimeout(function () { $("#demo1").jstree("set_focus"); }, 500);
	//setTimeout(function () { $.jstree._focused().select_node("#ch_6"); }, 1000);
	//setTimeout(function () { $.jstree._reference("#ch_6").close_node("#ch_6"); }, 1500);
		$("#demo1").bind("open_node.jstree", function (e, data) {data.inst.select_node("#ch_6", true);});
	//setTimeout(function () { $.jstree._reference("#ch_1").open_node("#ch_6"); }, 2500);
});



</script>

</html>

